﻿using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;
using System.Net.Mail;
using System.Net;
using System.Net.Mime;
using Soussous.Business;
using Soussous.DAO;
using Soussous.DAO.Impl;

namespace Soussous.Tools
{
    public class Helper
    {
        public static bool checkMail(String inEmail)
        {
            Regex regEmail = new Regex(@"^([\w\-.]+)@([a-zA-Z0-9\-.]+)$");
            Match monMatch = regEmail.Match(inEmail);
            return monMatch.Success;
        }

        public static void SendMail(string exp,string to,string sub,string body)
        {
            
            MailAddress from = new MailAddress(exp);
            MailAddress tos = new MailAddress(to);
            MailMessage mail = new MailMessage(from,tos);
            
            mail.Subject = sub;
            mail.Body = body;

            try
            {
                SmtpClient smtp = new SmtpClient("smtp.aliceadsl.fr");
                smtp.Send(mail);
            }
            catch (Exception)
            {

            }

        }

        public static void printSelect(HtmlSelect id, List<User> user) {
            
            foreach (User u in user) {

                id.Items.Add(u.Email);

            }
            
            
        }

    }
}
